import { Component, _decorator, tween, v3 } from 'cc';
const { ccclass, property ,menu} = _decorator;

@ccclass('ComShakeAction')
@menu("扩展组件/ComShakeAction")
export class ComShakeAction extends Component {

    //单次移动时间
    @property duration: number = 1.0;

    private tween: any;

    start() {

    }

    onEnable(){
        this.tween = tween(this.node).repeatForever(tween(this.node)
            .to(0.5 / this.duration, { scale: v3(1,1.1,1), angle: -10 })
            .to(0.5 / this.duration, { scale: v3(1,1,1), angle: 0 })
            .to(0.5 / this.duration, { scale: v3(1,1.1,1), angle: 10 })
            .to(0.5 / this.duration, { scale: v3(1,1,1), angle: 0 })
        ).start();
    }

    onDisable() {
        if (this.tween) {
            this.tween.stop();
            this.tween = null;         
        }
    }
    update(deltaTime: number) {
        
    }
}



